﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ZoneLine.Views
{
    /// <summary>
    /// AlarmView.xaml 的交互逻辑
    /// </summary>
    public partial class AlarmView : Window
    {
        public static AlarmView _view;

        public static AlarmView GetView()
        {
            if (_view == null)
            {
                _view = new AlarmView();
            }
            return _view;
        }


        private Action _closeViewAct;

        private AlarmView()
        {
            InitializeComponent();
            this.Closed += AlarmView_Closed;
        }

        public void SetInfo(string alarmMsg, Action act)
        {
            this.AlarmInfo.Text = alarmMsg;
            _closeViewAct = act;
        }

        private void AlarmView_Closed(object sender, EventArgs e)
        {
            _closeViewAct?.Invoke();
            _view = null;
        }
    }
}
